% Remember to use the lgrind style

\Head{}
\File{min.txt}{2007}{10}{28}{21:09}{1349}
\index{generateSolutionMin}\Proc{generateSolutionMin}\L{\LB{\K{static}_\V{WICOutput}_\V{generateSolutionMin}(\V{WICInput}_\V{inputData})\{}}
\L{\LB{}\Tab{8}{}}
\L{\LB{}\Tab{8}{\K{int}[\,]_\V{ySet}_=_\V{inputData}.\V{getYSet}().\V{clone}();_}}
\L{\LB{}\Tab{8}{\K{int}_\V{n}_=_\V{inputData}.\V{getN}();}}
\L{\LB{}\Tab{8}{}}
\L{\LB{}\Tab{8}{\V{Vector}\<\K{int}[\,]\>_\V{solution}_=_\K{new}_\V{Vector}\<\K{int}[\,]\>();_}}
\L{\LB{}\Tab{8}{}}
\L{\LB{}\Tab{8}{\K{int}_\V{a},\V{b},\V{c}_=_\N{0};_\C{}//_[a,b]_defines_the_interval,_c_is_the_weight\CE{}}}
\L{\LB{}\Tab{8}{}}
\L{\LB{}\Tab{8}{\K{while}(\K{true})\{}}
\L{\LB{}\Tab{16}{\C{}//_\_Step_1\_:_find_the_index_of_the_minimum_number_\<\>_0\CE{}}}
\L{\LB{}\Tab{16}{\K{int}_\V{indexOfMin}_=_\N{0};_\C{}//NOTE:_ySet[0]_could_be_0\CE{}}}
\L{\LB{}\Tab{16}{\K{for}(\K{int}_\V{i}=\N{1};_\V{i}\<\V{n};_\V{i}++)}}
\L{\LB{}\Tab{24}{\K{if}(_(\V{ySet}[\V{indexOfMin}]_==_\N{0})_\|\,\|_}}
\L{\LB{}\Tab{40}{(_(\V{ySet}[\V{i}]_!=_\N{0})_\&\&_(\V{ySet}[\V{i}]_\<_\V{ySet}[\V{indexOfMin}])_)_)}}
\L{\LB{}\Tab{32}{\V{indexOfMin}_=_\V{i};}}
\L{\LB{}\Tab{16}{}}
\L{\LB{}\Tab{16}{\C{}//this_means_that_the_algorithm_can_terminate,_all_the_numbers_are_0\CE{}}}
\L{\LB{}\Tab{16}{\K{if}(\V{ySet}[\V{indexOfMin}]_==_\N{0})_}}
\L{\LB{}\Tab{24}{\K{break};}}
\L{\LB{}\Tab{8}{}}
\L{\LB{}\Tab{16}{\C{}//_\_Step_2\_:_find_the_interval\CE{}}}
\L{\LB{}\Tab{16}{\C{}//setup_the_initial_small_interval._The_indexes_start_from_0,_therefore_at_the_end_\CE{}}}
\L{\LB{}\Tab{16}{\C{}//_all_of_these_values_must_be_increased_by_1._We_don{'}t_do_that_now_to_avoid_issues\CE{}}}
\L{\LB{}\Tab{16}{\C{}//_with_the_indexes_and_confusion\CE{}}}
\L{\LB{}\Tab{16}{\V{a}_=_\V{indexOfMin};}}
\L{\LB{}\Tab{16}{\V{b}_=_\V{indexOfMin}_+_\N{1};}}
\L{\LB{}\Tab{16}{\V{c}_=_\V{ySet}[\V{indexOfMin}];}}
\L{\LB{}\Tab{16}{}}
\L{\LB{}\Tab{16}{\C{}//try_to_extend_it_to_the_left\CE{}}}
\L{\LB{}\Tab{16}{\K{while}(_(\V{a}_\>_\N{0})_\&\&_(\V{ySet}[\V{a}\-\N{1}]_\>=_\V{c})_)}}
\L{\LB{}\Tab{24}{\V{a}\-\-;}}
\L{\LB{}\Tab{16}{}}
\L{\LB{}\Tab{16}{\C{}//try_to_extend_it_to_the_right\CE{}}}
\L{\LB{}\Tab{16}{\K{while}(_(\V{b}_\<_\V{n})_\&\&_(\V{ySet}[\V{b}]_\>=_\V{c})_)}}
\L{\LB{}\Tab{24}{\V{b}++;}}
\L{\LB{}\Tab{16}{}}
\L{\LB{}\Tab{16}{\C{}//update_the_values_covered_by_the_interval\CE{}}}
\L{\LB{}\Tab{16}{\K{for}(\K{int}_\V{i}=\V{a};_\V{i}\<\V{b};_\V{i}++)}}
\L{\LB{}\Tab{24}{\V{ySet}[\V{i}]_=_\V{ySet}[\V{i}]_\-_\V{c};}}
\L{\LB{}\Tab{16}{}}
\L{\LB{}\Tab{16}{\C{}//add_the_triple_to_the_solution_set._Adjust_the_values_too\CE{}}}
\L{\LB{}\Tab{16}{\V{solution}.\V{add}(\K{new}_\K{int}[\,]\{\V{a}+\N{1},\V{b}+\N{1},\V{c}\});}}
\L{\LB{}\Tab{8}{\}}}
\L{\LB{}\Tab{8}{}}
\L{\LB{}\Tab{8}{\K{return}_\K{new}_\V{WICOutput}(\V{solution},\V{solution}.\V{size}());}}
\L{\LB{\}}}
